<?php

	require_once 'config.php';
	
	$menu_name = "";
	 
	 echo $_GET["SID"];
	//get index menu ex Specials, Where to Stay... 
	
	$query = db_select('menu_links', 'm') 
		  ->condition('m.menu_name', $menu_name)  
		  ->condition('m.hidden', 1, '<>') 
		  ->condition('m.plid', $_GET["SID"])
		  ->fields('m', array('link_title', 'menu_name', 'link_path', 'mlid'));
	  
	$result = $query->execute();
	 
	foreach ($result as $record) {
	  	$linkPath = $record->link_path;
		 
	  	$query2 = db_select('menu_router', 'r') 
		  	->condition('r.path', $linkPath);    
		  
		$result2 = $query2->countQuery()->execute()->fetchField();;
		
		if($result2 > 0){
			echo "<a href='SubPage.php?SID=".$record->mlid."'>".$record->link_title."</a><br/>";
		}  
	}
	
?>